﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Eratosthenes
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine(string.Join("\n", Sieve(100)));
            }
            finally
            {
                Console.ReadKey();
            }
        }
        static List<int> Sieve(int n)
        {
            if (n < 2) throw new ArgumentException();
            bool[] map = new bool[n + 1];
            var list = new List<int>();
            for(int i = 2; i <= n; i++)
            {
                for(int j = i; i * j <= n; j++)
                {
                    map[i * j] = true;
                }
                if (!map[i]) list.Add(i);
            }
            return list;
        }
    }
}
